<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="./font/iconfont.css">
    <style type="text/css">
        body,
        html {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }

        #allmap {
            width: 100%;
            height: 100%;
        }

        .queryContainer {
            text-align: center;
            line-height: 50px;
            width: 300px;
            height: 50px;
            background: #1e9ee9;
            border-radius: 15px;
            opacity: 0.8;
            left: 160px;
            top: 20px;
            position: absolute;
        }

        .origin i {
            font-size: 30px;
            color: #1e9ee9;
        }
    </style>
    <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=你的密钥"></script>
    <title>百度地图demo</title>
</head>

<body>
    <div id="allmap"></div>
    <div class="queryContainer">
        <label for="city">城市名: </label><input type="text" name="city" id="city" onkeydown="isSubmit(event)">
        <button onclick="locating()">定位</button>
    </div>
</body>

</html>
<script type="text/javascript">
    var map = new BMap.Map("allmap");
    map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
    var transit = new BMap.TransitRoute(map, {
        renderOptions: {
            map: map,
            autoViewport: true
        }
    });
    var start = new BMap.Point(116.310791, 40.003419);
    var end = new BMap.Point(116.486419, 39.877282);
    transit.search(start, end);
</script>